package com.commonlover.controller;

import com.commonlover.result.WebResult;
import com.commonlover.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("category")
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping("findCategoryByAuthorId")
    public WebResult<List<HashMap<String, Object>>> findCategoryByAuthorId(Integer id) {
        return WebResult.<List<HashMap<String, Object>>>builder()
                .code(200)
                .message(WebResult.REQUEST_STATUS_SUCCESS)
                .data(categoryService.findCategoryByAuthorId(id))
                .build();
    }
}
